package com.ac.scum.log.web.model.dashboard;

import com.ac.common.core.exception.BaseException;
import com.ac.common.core.result.Result;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 首页
 */
@Slf4j
@RestController
@AllArgsConstructor
@RequestMapping("dashboard")
public class DashboardController {

    private final DashboardService dashboardService;

    /**
     * 加载首页数据
     */
    @GetMapping("load")
    public Result<Dashboard> load() throws BaseException {
        try {
            return Result.ok(dashboardService.load());
        } catch (BaseException e) {
            throw e;
        } catch (Exception e) {
            e.printStackTrace();
            return Result.failure(e.getMessage());
        }
    }
}
